/*
 +----------------------------------------------------------------------
 | @author    Candison November (www.kandisheng.com)
 | @copyright SosoSoft (www.sososoft.om)
 | @location  Nanjing China
 | @time      2015-06-27
 | @version   20150627
 +----------------------------------------------------------------------
 */
//定义加入收藏夹函数
function join_favorite(siteUrl, siteName) {
    //捕获加入收藏过程中的异常
    try {
//判断浏览器是否支持document.all
        if (document.all) {
//如果支持则用external方式加入收藏夹
            window.external.addFavorite(siteUrl, siteName);
        } else if (window.sidebar) {
            //如果支持window.sidebar，则用下列方式加入收藏夹
            window.sidebar.addPanel(siteName, siteUrl, '');
        }
    }
        //处理异常
    catch (e) {
        alert("加入收藏夹失败，请使用Ctrl+D快捷键进行添加操作!");
    }
}

function AddToFavorites() {
    var title = document.title;
    var url = location.href;
    if (window.sidebar) // Firefox
        window.sidebar.addPanel(title, url, '');
    else if (window.opera && window.print) // Opera
    {
        var elem = document.createElement('a');
        elem.setAttribute('href', url);
        elem.setAttribute('title', title);
        elem.setAttribute('rel', 'sidebar'); // required to work in opera 7+
        elem.click();
    }
    else if (document.all) // IE
        window.external.AddFavorite(url, title);
}
function search() {
    var keyword = $("#searchInput").val();
    if (keyword == "") {
        alert("请输入关键词");
    } else {
        window.location.href = '/shop/artwork/group/keyword/' + keyword;
    }

}

(function () {
    $(window).load(function () {
        $(".slideBoxArtwork").slide({
            mainCell: ".bd ul",
            effect: "fold",
            autoPlay: true
        });
    });
    $(document).ready(function () {
        $(".slideBox").slide({
            mainCell: ".bd ul",
            effect: "fold",
            autoPlay: true
        });

        $(".classification").find("li").on("mouseover", function () {
            $(this).find("span").hide();
            $(this).find("span").removeClass("active");
        });
        $(".classification").find("li").on("mouseout", function () {
            $(this).find("span").show();
            $(this).find("span").addClass("active");
        });
        //$(".artists").find("li").on("mouseover", function () {
        //    $(this).find("span").hide();
        //    $(this).find("span").removeClass("active");
        //});
        //$(".artists").find("li").on("mouseout", function () {
        //    $(this).find("span").show();
        //    $(this).find("span").addClass("active");
        //});
        $("#favorite").on("click", function () {
            //alert(0);
            AddToFavorites();
            //join_favorite(window.location,document.title);
        });
        $("#searchButton").on("click", function () {
            search();
        });
        $("#searchInput").on("keypress", function (event) {
            if (event.keyCode == "13") {
                search();
            }
        });
        $("#menu_artwork").on("mouseover", function () {
            $(".popmenu").show();
        });
        $(".popmenu").on("mouseleave", function () {
            $(".popmenu").hide();
        });
    });
})();


